import java.util.*;
import java.io.*;
public class Main
{
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read in = new Read();

    public static void Swap(char[] s, int i, int j) {
        char tmp = s[i];
        s[i] = s[j];
        s[j] = tmp;
    }
    public static void main(String[] args) throws IOException {
        int q = in.nextInt();
        while(q-- != 0) {
            char[] s = in.next().toCharArray();
            int n = s.length;
            for(int i = n - 1; i >= 0; i--) {
                if((s[i] - '0') % 2 == 0) {
                    Swap(s, i, n - 1);
                    break;
                }
            }
            if((s[n - 1] - '0') % 2 == 0) {
                out.println(s);
            } else {
                out.println(-1);
            }
        }
        out.close();
    }
}
class Read {
    StringTokenizer st = new StringTokenizer("");
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String next() throws IOException {
        while(!st.hasMoreTokens()) {
            st = new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }

    String nextLine() throws IOException {
        return bf.readLine();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}

